﻿<UserControl x:Class="Chapters.Chapter11.Viewport2DVisual3DExample"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<Grid>
		<Viewport3D>
			<Viewport3D.Camera>
				<PerspectiveCamera FieldOfView="60"
								   Position="0,0.5,3"
								   LookDirection="0,-0.5,-3"
								   UpDirection="0,1,0" />
			</Viewport3D.Camera>

			<Viewport2DVisual3D>
				<Viewport2DVisual3D.Geometry>
					<MeshGeometry3D Positions="-0.625,0.5,0 0.625,0.5,0 0.625,-0.5,0 -0.625,-0.5,0."
									Normals="0,0,1 0,0,1 0,0,1 0,0,1"
									TriangleIndices="0,3,2 0,2,1"
									TextureCoordinates="0,0 1,0 1,1 0,1" />
				</Viewport2DVisual3D.Geometry>

				<Viewport2DVisual3D.Material>
					<DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" />
				</Viewport2DVisual3D.Material>

				<Viewport2DVisual3D.Transform>
					<RotateTransform3D>
						<RotateTransform3D.Rotation>
							<AxisAngleRotation3D x:Name="_rotation"
												 Axis="0,1,0"
												 Angle="-45" />
						</RotateTransform3D.Rotation>
					</RotateTransform3D>
				</Viewport2DVisual3D.Transform>
				<ListBox>
					<TextBlock>Welcome</TextBlock>
					<TextBlock>To</TextBlock>
					<TextBlock>The</TextBlock>
					<TextBlock>World</TextBlock>
					<TextBlock>Of</TextBlock>
					<Button>Interactive</Button>
					<TextBlock>2D on 3D</TextBlock>
				</ListBox>
			</Viewport2DVisual3D>

			<ModelVisual3D>
				<ModelVisual3D.Content>
					<AmbientLight Color="White" />
				</ModelVisual3D.Content>
			</ModelVisual3D>
		</Viewport3D>
	</Grid>

	<UserControl.Triggers>
		<EventTrigger RoutedEvent="UserControl.Loaded">
			<BeginStoryboard>
				<Storyboard>
					<DoubleAnimation To="45"
									 AutoReverse="True"
									 Duration="0:0:3"
									 RepeatBehavior="Forever"
									 Storyboard.TargetName="_rotation"
									 Storyboard.TargetProperty="Angle" />
				</Storyboard>
			</BeginStoryboard>
		</EventTrigger>
	</UserControl.Triggers>
</UserControl>